home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / get_cmt.arj / LEXYY.C < prev   
C/C++ Source or Header  |  1991-01-06  |  30KB  |  1,157 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8.  
  9. #include <stdio.h>
  10.  
  11.  
  12. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  13. #ifdef c_plusplus
  14. #ifndef __cplusplus
  15. #define __cplusplus
  16. #endif
  17. #endif
  18.  
  19.  
  20. #ifdef __cplusplus
  21.  
  22. #include <stdlib.h>
  23. #include <osfcn.h>
  24.  
  25. /* use prototypes in function declarations */
  26. #define YY_USE_PROTOS
  27.  
  28. /* the "const" storage-class-modifier is valid */
  29. #define YY_USE_CONST
  30.  
  31. #else    /* ! __cplusplus */
  32.  
  33. #ifdef __STDC__
  34.  
  35. #ifdef __GNUC__
  36. #include <stddef.h>
  37. void *malloc( size_t );
  38. void free( void* );
  39. #else
  40. #include <stdlib.h>
  41. #endif    /* __GNUC__ */
  42.  
  43. #define YY_USE_PROTOS
  44. #define YY_USE_CONST
  45.  
  46. #endif    /* __STDC__ */
  47. #endif    /* ! __cplusplus */
  48.  
  49.  
  50. #if defined(__TURBOC__) || defined(MSDOS)
  51. #include <stdlib.h>
  52. #include <io.h>
  53. #define YY_USE_CONST
  54. #define YY_USE_PROTOS
  55. #endif
  56.  
  57. #ifndef YY_USE_CONST
  58. #define const
  59. #endif
  60.  
  61. #ifdef YY_USE_PROTOS
  62. #define YY_PROTO(proto) proto
  63. #else
  64. #define YY_PROTO(proto) ()
  65. /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
  66.  * so it's got to be a K&R compiler, and therefore there's no standard
  67.  * place from which to include these definitions
  68.  */
  69. char *malloc();
  70. int free();
  71. int read();
  72. #endif
  73.  
  74.  
  75. /* amount of stuff to slurp up with each read */
  76. #ifndef YY_READ_BUF_SIZE
  77. #define YY_READ_BUF_SIZE 8192
  78. #endif
  79.  
  80. /* returned upon end-of-file */
  81. #define YY_END_TOK 0
  82.  
  83. /* copy whatever the last rule matched to the standard output */
  84.  
  85. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  86. /* this used to be an fputs(), but since the string might contain NUL's,
  87.  * we now use fwrite()
  88.  */
  89. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  90.  
  91. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  92.  * is returned in "result".
  93.  */
  94. #define YY_INPUT(buf,result,max_size) \
  95.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  96.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  97. #define YY_NULL 0
  98.  
  99. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  100.  * we don't want an extra ';' after the "return" because that will cause
  101.  * some compilers to complain about unreachable statements.
  102.  */
  103. #define yyterminate() return ( YY_NULL )
  104.  
  105. /* report a fatal error */
  106.  
  107. /* The funky do-while is used to turn this macro definition into
  108.  * a single C statement (which needs a semi-colon terminator).
  109.  * This avoids problems with code like:
  110.  *
  111.  *     if ( something_happens )
  112.  *        YY_FATAL_ERROR( "oops, the something happened" );
  113.  *    else
  114.  *        everything_okay();
  115.  *
  116.  * Prior to using the do-while the compiler would get upset at the
  117.  * "else" because it interpreted the "if" statement as being all
  118.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  119.  */
  120.  
  121. #define YY_FATAL_ERROR(msg) \
  122.     do \
  123.         { \
  124.         (void) fputs( msg, stderr ); \
  125.         (void) putc( '\n', stderr ); \
  126.         exit( 1 ); \
  127.         } \
  128.     while ( 0 )
  129.  
  130. /* default yywrap function - always treat EOF as an EOF */
  131. #define yywrap() 1
  132.  
  133. /* enter a start condition.  This macro really ought to take a parameter,
  134.  * but we do it the disgusting crufty way forced on us by the ()-less
  135.  * definition of BEGIN
  136.  */
  137. #define BEGIN yy_start = 1 + 2 *
  138.  
  139. /* action number for EOF rule of a given start state */
  140. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  141.  
  142. /* special action meaning "start processing a new file" */
  143. #define YY_NEW_FILE \
  144.     do \
  145.         { \
  146.         yy_init_buffer( yy_current_buffer, yyin ); \
  147.         yy_load_buffer_state(); \
  148.         } \
  149.     while ( 0 )
  150.  
  151. /* default declaration of generated scanner - a define so the user can
  152.  * easily add parameters
  153.  */
  154. #define YY_DECL int yylex YY_PROTO(( void )) 
  155.  
  156. /* code executed at the end of each rule */
  157. #define YY_BREAK break;
  158.  
  159. #define YY_END_OF_BUFFER_CHAR 0
  160.  
  161. #ifndef YY_BUF_SIZE
  162. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  163. #endif
  164.  
  165. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  166.  
  167. #define YY_CHAR char
  168. # line 1 "get_cmt.l"
  169. #define INITIAL 0
  170. # line 2 "get_cmt.l"
  171.  
  172.     #include <string.h>
  173.  
  174.     #ifndef _MAX_PATH           /* if max. path length isn't defined,   */
  175.     #define _MAX_PATH 1024      /* we'll define a generous one.         */
  176.     #endif
  177.  
  178.     #define OUTPUT_BUF_SIZE  16384 /* The size of buffer we'll use on   */
  179.                                    /* the output, if we're not writing  */
  180.                                    /* to standard output                */
  181.  
  182.     int comments=0;
  183.     int line_numbers=0;
  184.     char *extensions[]={".C",".CPP",".CXX",".H",".HXX",".CC",NULL};
  185.  
  186.     int line_number;
  187. #define COMMENT 1
  188. # line 21 "get_cmt.l"
  189.  
  190. /* done after the current pattern has been matched and before the
  191.  * corresponding action - sets up yytext
  192.  */
  193. #define YY_DO_BEFORE_ACTION \
  194.     yytext = yy_bp; \
  195.     yyleng = yy_cp - yy_bp; \
  196.     yy_hold_char = *yy_cp; \
  197.     *yy_cp = '\0'; \
  198.     yy_c_buf_p = yy_cp;
  199.  
  200. #define EOB_ACT_CONTINUE_SCAN 0
  201. #define EOB_ACT_END_OF_FILE 1
  202. #define EOB_ACT_LAST_MATCH 2
  203.  
  204. /* return all but the first 'n' matched characters back to the input stream */
  205. #define yyless(n) \
  206.     do \
  207.         { \
  208.         /* undo effects of setting up yytext */ \
  209.         *yy_cp = yy_hold_char; \
  210.         yy_c_buf_p = yy_cp = yy_bp + n; \
  211.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  212.         } \
  213.     while ( 0 )
  214.  
  215. #define unput(c) yyunput( c, yytext )
  216.  
  217.  
  218. struct yy_buffer_state
  219.     {
  220.     FILE *yy_input_file;
  221.  
  222.     YY_CHAR *yy_ch_buf;        /* input buffer */
  223.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  224.  
  225.     /* size of input buffer in bytes, not including room for EOB characters*/
  226.     int yy_buf_size;    
  227.  
  228.     /* number of characters read into yy_ch_buf, not including EOB characters */
  229.     int yy_n_chars;
  230.  
  231.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  232. #define EOF_NOT_SEEN 0
  233.     /* "pending" happens when the EOF has been seen but there's still
  234.      * some text process
  235.      */
  236. #define EOF_PENDING 1
  237. #define EOF_DONE 2
  238.     };
  239.  
  240. static YY_BUFFER_STATE yy_current_buffer;
  241.  
  242. /* we provide macros for accessing buffer states in case in the
  243.  * future we want to put the buffer states in a more general
  244.  * "scanner state"
  245.  */
  246. #define YY_CURRENT_BUFFER yy_current_buffer
  247.  
  248.  
  249. /* yy_hold_char holds the character lost when yytext is formed */
  250. static YY_CHAR yy_hold_char;
  251.  
  252. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  253.  
  254.  
  255.  
  256. #ifndef YY_USER_ACTION
  257. #define YY_USER_ACTION
  258. #endif
  259.  
  260. #ifndef YY_USER_INIT
  261. #define YY_USER_INIT
  262. #endif
  263.  
  264. extern YY_CHAR *yytext;
  265. extern int yyleng;
  266. extern FILE *yyin, *yyout;
  267.  
  268. YY_CHAR *yytext;
  269. int yyleng;
  270.  
  271. FILE *yyin = stdin, *yyout = stdout;
  272.  
  273. #define YY_END_OF_BUFFER 12
  274. typedef int yy_state_type;
  275. static const short int yy_accept[32] =
  276.     {   0,
  277.         0,    0,    0,    0,   12,    9,   10,    9,    9,    9,
  278.         9,    2,    3,    2,    0,    6,    0,    0,    0,    5,
  279.         1,    0,    4,    0,    6,    0,    7,    0,    0,    8,
  280.         0
  281.     } ;
  282.  
  283. static const YY_CHAR yy_ec[128] =
  284.     {   0,
  285.         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
  286.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  287.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  288.         1,    1,    1,    3,    1,    1,    1,    1,    4,    1,
  289.         1,    5,    1,    1,    1,    1,    6,    7,    1,    1,
  290.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  291.         1,    1,    1,    1,    1,    1,    1,    1,    1,    7,
  292.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  293.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  294.         1,    8,    1,    1,    1,    1,    1,    1,    1,    1,
  295.  
  296.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  297.         1,    1,    1,    1,    1,    1,    1,    1,    1,    7,
  298.         1,    1,    1,    1,    1,    1,    1
  299.     } ;
  300.  
  301. static const YY_CHAR yy_meta[9] =
  302.     {   0,
  303.         1,    1,    1,    1,    1,    1,    1,    1
  304.     } ;
  305.  
  306. static const short int yy_base[37] =
  307.     {   0,
  308.         0,    0,    7,   11,   34,   45,   45,   14,   25,   23,
  309.        18,   45,   45,   22,   22,   45,   29,   23,   19,   45,
  310.        45,   19,   45,    0,    0,   36,   45,   16,   17,   45,
  311.        45,   17,   14,   13,   10,    9
  312.     } ;
  313.  
  314. static const short int yy_def[37] =
  315.     {   0,
  316.        31,    1,   32,   32,   31,   31,   31,   33,   34,   31,
  317.        31,   31,   31,   31,   33,   31,   35,   31,   31,   31,
  318.        31,   36,   31,   15,   15,   35,   31,   31,   36,   31,
  319.         0,   31,   31,   31,   31,   31
  320.     } ;
  321.  
  322. static const short int yy_nxt[54] =
  323.     {   0,
  324.         6,    7,    8,    9,   10,   11,    6,    6,   13,   29,
  325.        24,   14,   13,   18,   15,   14,   16,   12,   30,   27,
  326.        30,   17,   21,   22,   16,   28,   27,   23,   20,   17,
  327.        15,   25,   19,   31,   31,   31,   26,   15,   25,   31,
  328.        31,   31,   31,   26,    5,   31,   31,   31,   31,   31,
  329.        31,   31,   31
  330.     } ;
  331.  
  332. static const short int yy_chk[54] =
  333.     {   0,
  334.         1,    1,    1,    1,    1,    1,    1,    1,    3,   36,
  335.        35,    3,    4,   34,   33,    4,    8,   32,   29,   28,
  336.        22,    8,   11,   11,   15,   19,   18,   14,   10,   15,
  337.        17,   17,    9,    5,    0,    0,   17,   26,   26,    0,
  338.         0,    0,    0,   26,   31,   31,   31,   31,   31,   31,
  339.        31,   31,   31
  340.     } ;
  341.  
  342. static yy_state_type yy_last_accepting_state;
  343. static YY_CHAR *yy_last_accepting_cpos;
  344.  
  345. /* the intent behind this definition is that it'll catch
  346.  * any uses of REJECT which flex missed
  347.  */
  348. #define REJECT reject_used_but_not_detected
  349. #define yymore() yymore_used_but_not_detected
  350. #define YY_MORE_ADJ 0
  351.  
  352. /* these variables are all declared out here so that section 3 code can
  353.  * manipulate them
  354.  */
  355. /* points to current character in buffer */
  356. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  357. static int yy_init = 1;        /* whether we need to initialize */
  358. static int yy_start = 0;    /* start state number */
  359.  
  360. /* flag which is used to allow yywrap()'s to do buffer switches
  361.  * instead of setting up a fresh yyin.  A bit of a hack ...
  362.  */
  363. static int yy_did_buffer_switch_on_eof;
  364.  
  365. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  366. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  367. static int yy_get_next_buffer YY_PROTO(( void ));
  368. static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  369. void yyrestart YY_PROTO(( FILE *input_file ));
  370. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  371. void yy_load_buffer_state YY_PROTO(( void ));
  372. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  373. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  374. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  375.  
  376. #define yy_new_buffer yy_create_buffer
  377.  
  378. #ifdef __cplusplus
  379. static int yyinput YY_PROTO(( void ));
  380. #else
  381. static int input YY_PROTO(( void ));
  382. #endif
  383.  
  384. YY_DECL
  385.     {
  386.     register yy_state_type yy_current_state;
  387.     register YY_CHAR *yy_cp, *yy_bp;
  388.     register int yy_act;
  389.  
  390.  
  391.  
  392.  
  393.     if ( yy_init )
  394.     {
  395.     YY_USER_INIT;
  396.  
  397.     if ( ! yy_start )
  398.         yy_start = 1;    /* first start state */
  399.  
  400.     if ( ! yyin )
  401.         yyin = stdin;
  402.  
  403.     if ( ! yyout )
  404.         yyout = stdout;
  405.  
  406.     if ( yy_current_buffer )
  407.         yy_init_buffer( yy_current_buffer, yyin );
  408.     else
  409.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  410.  
  411.     yy_load_buffer_state();
  412.  
  413.     yy_init = 0;
  414.     }
  415.  
  416.     while ( 1 )        /* loops until end-of-file is reached */
  417.     {
  418.     yy_cp = yy_c_buf_p;
  419.  
  420.     /* support of yytext */
  421.     *yy_cp = yy_hold_char;
  422.  
  423.     /* yy_bp points to the position in yy_ch_buf of the start of the
  424.      * current run.
  425.      */
  426.     yy_bp = yy_cp;
  427.  
  428.     yy_current_state = yy_start;
  429. yy_match:
  430.     do
  431.         {
  432.         register YY_CHAR yy_c = yy_ec[*yy_cp];
  433.         if ( yy_accept[yy_current_state] )
  434.         {
  435.         yy_last_accepting_state = yy_current_state;
  436.         yy_last_accepting_cpos = yy_cp;
  437.         }
  438.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  439.         {
  440.         yy_current_state = yy_def[yy_current_state];
  441.         if ( yy_current_state >= 32 )
  442.             yy_c = yy_meta[yy_c];
  443.         }
  444.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  445.         ++yy_cp;
  446.         }
  447.     while ( yy_current_state != 31 );
  448.     yy_cp = yy_last_accepting_cpos;
  449.     yy_current_state = yy_last_accepting_state;
  450.  
  451. yy_find_action:
  452.     yy_act = yy_accept[yy_current_state];
  453.  
  454.     YY_DO_BEFORE_ACTION;
  455.     YY_USER_ACTION;
  456.  
  457. do_action:    /* this label is used only to access EOF actions */
  458.  
  459.  
  460.     switch ( yy_act )
  461.         {
  462.         case 0: /* must backtrack */
  463.         /* undo the effects of YY_DO_BEFORE_ACTION */
  464.         *yy_cp = yy_hold_char;
  465.         yy_cp = yy_last_accepting_cpos;
  466.         yy_current_state = yy_last_accepting_state;
  467.         goto yy_find_action;
  468.  
  469. case 1:
  470. # line 23 "get_cmt.l"
  471. {
  472.             if (line_numbers)
  473.                 fprintf(yyout,"%.4d:",line_number);
  474.             comments ++;
  475.             BEGIN COMMENT;
  476.          }
  477.     YY_BREAK
  478. case 2:
  479. # line 30 "get_cmt.l"
  480. {
  481.                     fprintf(yyout,"%c",*yytext);
  482.                 }
  483.     YY_BREAK
  484. case 3:
  485. # line 34 "get_cmt.l"
  486. {
  487.                     line_number++;
  488.                     fprintf(yyout,"\n");
  489.                     if (line_numbers)
  490.                         fprintf(yyout,"%.4d:",line_number);
  491.                 }
  492.     YY_BREAK
  493. case 4:
  494. # line 41 "get_cmt.l"
  495. {
  496.                     fprintf(yyout,"\n");
  497.                     BEGIN INITIAL;
  498.                 }
  499.     YY_BREAK
  500. case 5:
  501. # line 46 "get_cmt.l"
  502. {
  503.                   fprintf(yyout,"\n\n%.4d: Error: found close comment outside \
  504.  of comment.\n\n",line_number);
  505.                 }
  506.     YY_BREAK
  507. case 6:
  508. # line 51 "get_cmt.l"
  509. ;   /* This recognizes and ignores string constants */
  510.     YY_BREAK
  511. case 7:
  512. # line 52 "get_cmt.l"
  513. ;   /* This does the same for character constants   */
  514.     YY_BREAK
  515. case 8:
  516. *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
  517. yy_c_buf_p = yy_cp -= 1;
  518. YY_DO_BEFORE_ACTION; /* set up yytext again */
  519. # line 53 "get_cmt.l"
  520. {
  521.                         char *line=yytext+2;
  522.                         fprintf(yyout,"%s\n",line);
  523.                     }
  524.     YY_BREAK
  525. case 9:
  526. # line 58 "get_cmt.l"
  527. ;
  528.     YY_BREAK
  529. case 10:
  530. # line 59 "get_cmt.l"
  531. line_number++;
  532.     YY_BREAK
  533. case 11:
  534. # line 61 "get_cmt.l"
  535. ECHO;
  536.     YY_BREAK
  537. case YY_STATE_EOF(INITIAL):
  538. case YY_STATE_EOF(COMMENT):
  539.     yyterminate();
  540.  
  541.         case YY_END_OF_BUFFER:
  542.         {
  543.         /* amount of text matched not including the EOB char */
  544.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  545.  
  546.         /* undo the effects of YY_DO_BEFORE_ACTION */
  547.         *yy_cp = yy_hold_char;
  548.  
  549.         /* note that here we test for yy_c_buf_p "<=" to the position
  550.          * of the first EOB in the buffer, since yy_c_buf_p will
  551.          * already have been incremented past the NUL character
  552.          * (since all states make transitions on EOB to the end-
  553.          * of-buffer state).  Contrast this with the test in yyinput().
  554.          */
  555.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  556.             /* this was really a NUL */
  557.             {
  558.             yy_state_type yy_next_state;
  559.  
  560.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  561.  
  562.             yy_current_state = yy_get_previous_state();
  563.  
  564.             /* okay, we're now positioned to make the
  565.              * NUL transition.  We couldn't have
  566.              * yy_get_previous_state() go ahead and do it
  567.              * for us because it doesn't know how to deal
  568.              * with the possibility of jamming (and we
  569.              * don't want to build jamming into it because
  570.              * then it will run more slowly)
  571.              */
  572.  
  573.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  574.  
  575.             yy_bp = yytext + YY_MORE_ADJ;
  576.  
  577.             if ( yy_next_state )
  578.             {
  579.             /* consume the NUL */
  580.             yy_cp = ++yy_c_buf_p;
  581.             yy_current_state = yy_next_state;
  582.             goto yy_match;
  583.             }
  584.  
  585.             else
  586.             {
  587.                 yy_cp = yy_last_accepting_cpos;
  588.                 yy_current_state = yy_last_accepting_state;
  589.             goto yy_find_action;
  590.             }
  591.             }
  592.  
  593.         else switch ( yy_get_next_buffer() )
  594.             {
  595.             case EOB_ACT_END_OF_FILE:
  596.             {
  597.             yy_did_buffer_switch_on_eof = 0;
  598.  
  599.             if ( yywrap() )
  600.                 {
  601.                 /* note: because we've taken care in
  602.                  * yy_get_next_buffer() to have set up yytext,
  603.                  * we can now set up yy_c_buf_p so that if some
  604.                  * total hoser (like flex itself) wants
  605.                  * to call the scanner after we return the
  606.                  * YY_NULL, it'll still work - another YY_NULL
  607.                  * will get returned.
  608.                  */
  609.                 yy_c_buf_p = yytext + YY_MORE_ADJ;
  610.  
  611.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  612.                 goto do_action;
  613.                 }
  614.  
  615.             else
  616.                 {
  617.                 if ( ! yy_did_buffer_switch_on_eof )
  618.                 YY_NEW_FILE;
  619.                 }
  620.             }
  621.             break;
  622.  
  623.             case EOB_ACT_CONTINUE_SCAN:
  624.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  625.  
  626.             yy_current_state = yy_get_previous_state();
  627.  
  628.             yy_cp = yy_c_buf_p;
  629.             yy_bp = yytext + YY_MORE_ADJ;
  630.             goto yy_match;
  631.  
  632.             case EOB_ACT_LAST_MATCH:
  633.             yy_c_buf_p =
  634.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  635.  
  636.             yy_current_state = yy_get_previous_state();
  637.  
  638.             yy_cp = yy_c_buf_p;
  639.             yy_bp = yytext + YY_MORE_ADJ;
  640.             goto yy_find_action;
  641.             }
  642.         break;
  643.         }
  644.  
  645.         default:
  646. #ifdef FLEX_DEBUG
  647.         printf( "action # %d\n", yy_act );
  648. #endif
  649.         YY_FATAL_ERROR(
  650.             "fatal flex scanner internal error--no action found" );
  651.         }
  652.     }
  653.     }
  654.  
  655.  
  656. /* yy_get_next_buffer - try to read in a new buffer
  657.  *
  658.  * synopsis
  659.  *     int yy_get_next_buffer();
  660.  *     
  661.  * returns a code representing an action
  662.  *     EOB_ACT_LAST_MATCH - 
  663.  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  664.  *     EOB_ACT_END_OF_FILE - end of file
  665.  */
  666.  
  667. static int yy_get_next_buffer()
  668.  
  669.     {
  670.     register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  671.     register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  672.     register int number_to_move, i;
  673.     int ret_val;
  674.  
  675.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  676.     YY_FATAL_ERROR(
  677.         "fatal flex scanner internal error--end of buffer missed" );
  678.  
  679.     /* try to read more data */
  680.  
  681.     /* first move last chars to start of buffer */
  682.     number_to_move = yy_c_buf_p - yytext;
  683.  
  684.     for ( i = 0; i < number_to_move; ++i )
  685.     *(dest++) = *(source++);
  686.  
  687.     if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  688.     /* don't do the read, it's not guaranteed to return an EOF,
  689.      * just force an EOF
  690.      */
  691.     yy_n_chars = 0;
  692.  
  693.     else
  694.     {
  695.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  696.  
  697.     if ( num_to_read > YY_READ_BUF_SIZE )
  698.         num_to_read = YY_READ_BUF_SIZE;
  699.  
  700.     else if ( num_to_read <= 0 )
  701.         YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  702.  
  703.     /* read in more data */
  704.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  705.           yy_n_chars, num_to_read );
  706.     }
  707.  
  708.     if ( yy_n_chars == 0 )
  709.     {
  710.     if ( number_to_move == 1 )
  711.         {
  712.         ret_val = EOB_ACT_END_OF_FILE;
  713.         yy_current_buffer->yy_eof_status = EOF_DONE;
  714.         }
  715.  
  716.     else
  717.         {
  718.         ret_val = EOB_ACT_LAST_MATCH;
  719.         yy_current_buffer->yy_eof_status = EOF_PENDING;
  720.         }
  721.     }
  722.  
  723.     else
  724.     ret_val = EOB_ACT_CONTINUE_SCAN;
  725.  
  726.     yy_n_chars += number_to_move;
  727.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  728.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  729.  
  730.     /* yytext begins at the second character in yy_ch_buf; the first
  731.      * character is the one which preceded it before reading in the latest
  732.      * buffer; it needs to be kept around in case it's a newline, so
  733.      * yy_get_previous_state() will have with '^' rules active
  734.      */
  735.  
  736.     yytext = &yy_current_buffer->yy_ch_buf[1];
  737.  
  738.     return ( ret_val );
  739.     }
  740.  
  741.  
  742. /* yy_get_previous_state - get the state just before the EOB char was reached
  743.  *
  744.  * synopsis
  745.  *     yy_state_type yy_get_previous_state();
  746.  */
  747.  
  748. static yy_state_type yy_get_previous_state()
  749.  
  750.     {
  751.     register yy_state_type yy_current_state;
  752.     register YY_CHAR *yy_cp;
  753.  
  754.     yy_current_state = yy_start;
  755.  
  756.     for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  757.     {
  758.     register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  759.     if ( yy_accept[yy_current_state] )
  760.         {
  761.         yy_last_accepting_state = yy_current_state;
  762.         yy_last_accepting_cpos = yy_cp;
  763.         }
  764.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  765.         {
  766.         yy_current_state = yy_def[yy_current_state];
  767.         if ( yy_current_state >= 32 )
  768.         yy_c = yy_meta[yy_c];
  769.         }
  770.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  771.     }
  772.  
  773.     return ( yy_current_state );
  774.     }
  775.  
  776.  
  777. /* yy_try_NUL_trans - try to make a transition on the NUL character
  778.  *
  779.  * synopsis
  780.  *     next_state = yy_try_NUL_trans( current_state );
  781.  */
  782.  
  783. #ifdef YY_USE_PROTOS
  784. static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  785. #else
  786. static yy_state_type yy_try_NUL_trans( yy_current_state )
  787. register yy_state_type yy_current_state;
  788. #endif
  789.  
  790.     {
  791.     register int yy_is_jam;
  792.     register YY_CHAR *yy_cp = yy_c_buf_p;
  793.  
  794.     register YY_CHAR yy_c = 1;
  795.     if ( yy_accept[yy_current_state] )
  796.     {
  797.     yy_last_accepting_state = yy_current_state;
  798.     yy_last_accepting_cpos = yy_cp;
  799.     }
  800.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  801.     {
  802.     yy_current_state = yy_def[yy_current_state];
  803.     if ( yy_current_state >= 32 )
  804.         yy_c = yy_meta[yy_c];
  805.     }
  806.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  807.     yy_is_jam = (yy_current_state == 31);
  808.  
  809.     return ( yy_is_jam ? 0 : yy_current_state );
  810.     }
  811.  
  812.  
  813. #ifdef YY_USE_PROTOS
  814. static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  815. #else
  816. static void yyunput( c, yy_bp )
  817. YY_CHAR c;
  818. register YY_CHAR *yy_bp;
  819. #endif
  820.  
  821.     {
  822.     register YY_CHAR *yy_cp = yy_c_buf_p;
  823.  
  824.     /* undo effects of setting up yytext */
  825.     *yy_cp = yy_hold_char;
  826.  
  827.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  828.     { /* need to shift things up to make room */
  829.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  830.     register YY_CHAR *dest =
  831.         &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  832.     register YY_CHAR *source =
  833.         &yy_current_buffer->yy_ch_buf[number_to_move];
  834.  
  835.     while ( source > yy_current_buffer->yy_ch_buf )
  836.         *--dest = *--source;
  837.  
  838.     yy_cp += dest - source;
  839.     yy_bp += dest - source;
  840.     yy_n_chars = yy_current_buffer->yy_buf_size;
  841.  
  842.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  843.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  844.     }
  845.  
  846.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  847.     yy_cp[-2] = '\n';
  848.  
  849.     *--yy_cp = c;
  850.  
  851.     /* note: the formal parameter *must* be called "yy_bp" for this
  852.      *       macro to now work correctly
  853.      */
  854.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  855.     }
  856.  
  857.  
  858. #ifdef __cplusplus
  859. static int yyinput()
  860. #else
  861. static int input()
  862. #endif
  863.  
  864.     {
  865.     int c;
  866.     YY_CHAR *yy_cp = yy_c_buf_p;
  867.  
  868.     *yy_cp = yy_hold_char;
  869.  
  870.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  871.     {
  872.     /* yy_c_buf_p now points to the character we want to return.
  873.      * If this occurs *before* the EOB characters, then it's a
  874.      * valid NUL; if not, then we've hit the end of the buffer.
  875.      */
  876.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  877.         /* this was really a NUL */
  878.         *yy_c_buf_p = '\0';
  879.  
  880.     else
  881.         { /* need more input */
  882.         yytext = yy_c_buf_p;
  883.         ++yy_c_buf_p;
  884.  
  885.         switch ( yy_get_next_buffer() )
  886.         {
  887.         case EOB_ACT_END_OF_FILE:
  888.             {
  889.             if ( yywrap() )
  890.             {
  891.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  892.             return ( EOF );
  893.             }
  894.  
  895.             YY_NEW_FILE;
  896.  
  897. #ifdef __cplusplus
  898.             return ( yyinput() );
  899. #else
  900.             return ( input() );
  901. #endif
  902.             }
  903.             break;
  904.  
  905.         case EOB_ACT_CONTINUE_SCAN:
  906.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  907.             break;
  908.  
  909.         case EOB_ACT_LAST_MATCH:
  910. #ifdef __cplusplus
  911.             YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  912. #else
  913.             YY_FATAL_ERROR( "unexpected last match in input()" );
  914. #endif
  915.         }
  916.         }
  917.     }
  918.  
  919.     c = *yy_c_buf_p;
  920.     yy_hold_char = *++yy_c_buf_p;
  921.  
  922.     return ( c );
  923.     }
  924.  
  925.  
  926. #ifdef YY_USE_PROTOS
  927. void yyrestart( FILE *input_file )
  928. #else
  929. void yyrestart( input_file )
  930. FILE *input_file;
  931. #endif
  932.  
  933.     {
  934.     yy_init_buffer( yy_current_buffer, input_file );
  935.     yy_load_buffer_state();
  936.     }
  937.  
  938.  
  939. #ifdef YY_USE_PROTOS
  940. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  941. #else
  942. void yy_switch_to_buffer( new_buffer )
  943. YY_BUFFER_STATE new_buffer;
  944. #endif
  945.  
  946.     {
  947.     if ( yy_current_buffer == new_buffer )
  948.     return;
  949.  
  950.     if ( yy_current_buffer )
  951.     {
  952.     /* flush out information for old buffer */
  953.     *yy_c_buf_p = yy_hold_char;
  954.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  955.     yy_current_buffer->yy_n_chars = yy_n_chars;
  956.     }
  957.  
  958.     yy_current_buffer = new_buffer;
  959.     yy_load_buffer_state();
  960.  
  961.     /* we don't actually know whether we did this switch during
  962.      * EOF (yywrap()) processing, but the only time this flag
  963.      * is looked at is after yywrap() is called, so it's safe
  964.      * to go ahead and always set it.
  965.      */
  966.     yy_did_buffer_switch_on_eof = 1;
  967.     }
  968.  
  969.  
  970. #ifdef YY_USE_PROTOS
  971. void yy_load_buffer_state( void )
  972. #else
  973. void yy_load_buffer_state()
  974. #endif
  975.  
  976.     {
  977.     yy_n_chars = yy_current_buffer->yy_n_chars;
  978.     yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  979.     yyin = yy_current_buffer->yy_input_file;
  980.     yy_hold_char = *yy_c_buf_p;
  981.     }
  982.  
  983.  
  984. #ifdef YY_USE_PROTOS
  985. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  986. #else
  987. YY_BUFFER_STATE yy_create_buffer( file, size )
  988. FILE *file;
  989. int size;
  990. #endif
  991.  
  992.     {
  993.     YY_BUFFER_STATE b;
  994.  
  995.     b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  996.  
  997.     if ( ! b )
  998.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  999.  
  1000.     b->yy_buf_size = size;
  1001.  
  1002.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1003.      * we need to put in 2 end-of-buffer characters.
  1004.      */
  1005.     b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  1006.  
  1007.     if ( ! b->yy_ch_buf )
  1008.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1009.  
  1010.     yy_init_buffer( b, file );
  1011.  
  1012.     return ( b );
  1013.     }
  1014.  
  1015.  
  1016. #ifdef YY_USE_PROTOS
  1017. void yy_delete_buffer( YY_BUFFER_STATE b )
  1018. #else
  1019. void yy_delete_buffer( b )
  1020. YY_BUFFER_STATE b;
  1021. #endif
  1022.  
  1023.     {
  1024.     if ( b == yy_current_buffer )
  1025.     yy_current_buffer = (YY_BUFFER_STATE) 0;
  1026.  
  1027.     free( (char *) b->yy_ch_buf );
  1028.     free( (char *) b );
  1029.     }
  1030.  
  1031.  
  1032. #ifdef YY_USE_PROTOS
  1033. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1034. #else
  1035. void yy_init_buffer( b, file )
  1036. YY_BUFFER_STATE b;
  1037. FILE *file;
  1038. #endif
  1039.  
  1040.     {
  1041.     b->yy_input_file = file;
  1042.  
  1043.     /* we put in the '\n' and start reading from [1] so that an
  1044.      * initial match-at-newline will be true.
  1045.      */
  1046.  
  1047.     b->yy_ch_buf[0] = '\n';
  1048.     b->yy_n_chars = 1;
  1049.  
  1050.     /* we always need two end-of-buffer characters.  The first causes
  1051.      * a transition to the end-of-buffer state.  The second causes
  1052.      * a jam in that state.
  1053.      */
  1054.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1055.     b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  1056.  
  1057.     b->yy_buf_pos = &b->yy_ch_buf[1];
  1058.  
  1059.     b->yy_eof_status = EOF_NOT_SEEN;
  1060.     }
  1061. # line 61 "get_cmt.l"
  1062.  
  1063. int main(int argc,char **argv) {
  1064.  
  1065.     int  found=0;
  1066.     char file_name[_MAX_PATH];
  1067.     char **extension;
  1068.     char *name_end;
  1069.     char *output_buffer=NULL;
  1070.     char output_ext[5]="\0";
  1071.     char output_file[_MAX_PATH]="\0";
  1072.  
  1073.     line_number = 1;
  1074.     while (argv[1][0]=='-') {
  1075.         switch(argv[1][1]) {
  1076.             case 'l':
  1077.             case 'L':
  1078.                     line_numbers=1;
  1079.                     break;
  1080.             case 'e':
  1081.             case 'E':
  1082.                     strcpy(output_ext,argv[1]+2);
  1083.                     break;
  1084.             case 'o':
  1085.             case 'O':
  1086.                     strcpy(output_file,argv[1]+2);
  1087.                     break;
  1088.             default:
  1089.                     fprintf(stderr,"Usage:getcmt [-l][-?][filename [filename...]]"
  1090.                     "\n-l:  add line numbers before comments"
  1091.                     "\n-?:  Show this help"
  1092.                     "\n filenames may include normal DOS wildcards");
  1093.                     return 0;
  1094.         }
  1095.         argc--;
  1096.         argv++;
  1097.     }
  1098.  
  1099.     if (argc<2) {
  1100.         /* read standard input if no file name supplied */
  1101.         line_number=0;
  1102.         yylex();
  1103.     }
  1104.     else while (--argc) {
  1105.  
  1106.         comments=0;
  1107.         line_number=1;
  1108.         strcpy(file_name,*++argv);
  1109.         name_end=strchr(file_name,'\0');
  1110.         /* otherwise, open each file supplied in turn. */
  1111.         if ((yyin=fopen(file_name,"r"))==NULL && strchr(*argv,'.')==NULL) {
  1112.             for (found=0,extension=extensions;*extension;extension++) {
  1113.                 strcpy(name_end,*extension);
  1114.                 if ((yyin=fopen(file_name,"r"))!=NULL) {
  1115.                     found=1;
  1116.                     break;
  1117.                 }
  1118.             }
  1119.             if (!found) {
  1120.                 fprintf(yyout,"\n\n\tError: Unable to open %s\n",*argv);
  1121.                 continue;
  1122.             }
  1123.         }
  1124.         if (*output_ext) {
  1125.             strcpy(output_file,file_name);
  1126.             name_end=strchr(output_file,'.')+1;
  1127.             strcpy(name_end,output_ext);
  1128.             if ((yyout=fopen(output_file,"w"))==NULL)
  1129.                 yyout=stdout;
  1130.             else {
  1131.                 if (output_buffer==NULL)
  1132.                     output_buffer=malloc(OUTPUT_BUF_SIZE);
  1133.                 setvbuf(yyout,output_buffer,_IOFBF,OUTPUT_BUF_SIZE);
  1134.             }
  1135.         }
  1136.         else if (*output_file) {
  1137.             if ((yyout=fopen(output_file,"a"))==NULL)
  1138.                 yyout=stdout;
  1139.             else {
  1140.                 if (output_buffer==NULL)
  1141.                     output_buffer=malloc(OUTPUT_BUF_SIZE);
  1142.                 setvbuf(yyout,output_buffer,_IOFBF,OUTPUT_BUF_SIZE);
  1143.             }
  1144.  
  1145.         }
  1146.         fprintf(yyout,"\n\n\t%s\n",file_name);
  1147.         yylex();                        /* Do the real work. */
  1148.         fprintf(yyout,"\n");
  1149.         yyrestart(yyin);
  1150.         if (yyin !=stdin)
  1151.             fclose(yyin);
  1152.         if (yyout!=stdout)
  1153.             fclose(yyout);
  1154.     }
  1155.     return comments;
  1156. }
  1157.